package org.dandsoft.blackbox.laboratory.tools.generator;

/**
 * @author Vilyuzhanin Denis (Fin)
 */
public class WordGenerator {

    private int alphabetSize;
    private int rowsCount;
    private int minWordSize;
    private int maxWordSize;
    private int dictionarySize;
    private int[][] words;


    public void create() {
        words = new int[dictionarySize][];
        for (int i = 0; i < words.length; i++) {
            int wordLength = generateWordLength();
            words[i] = new int[wordLength];
            for (int j = 0; j < wordLength; j++) {
                words[i][j] = generateSymbol();
            }
        }
    }

    public int getWordsCount() {
        return words.length;
    }

    public int getWordLength(int word) {
        return words[word].length;
    }

    public int getSymbol(int word, int symbol) {
        return words[word][symbol];
    }

    public int randomWord() {
        return (int) (Math.random() * (words.length - 1));
    }

    protected int generateSymbol() {
        return (int) (Math.random() * alphabetSize);
    }

    protected int generateWordLength() {
        return (int) ((Math.random() * (maxWordSize - minWordSize)) + minWordSize);
    }

    public int getMinWordSize() {
        return minWordSize;
    }

    public void setMinWordSize(int minWordSize) {
        this.minWordSize = minWordSize;
    }

    public int getMaxWordSize() {
        return maxWordSize;
    }

    public void setMaxWordSize(int maxWordSize) {
        this.maxWordSize = maxWordSize;
    }

    public int[][] getWords() {
        return words;
    }

    public void setWords(int[][] words) {
        this.words = words;
    }

    public int getAlphabetSize() {
        return alphabetSize;
    }

    public void setAlphabetSize(int alphabetSize) {
        this.alphabetSize = alphabetSize;
    }

    public int getRowsCount() {
        return rowsCount;
    }

    public void setRowsCount(int rowsCount) {
        this.rowsCount = rowsCount;
    }

    public int getDictionarySize() {
        return dictionarySize;
    }

    public void setDictionarySize(int dictionarySize) {
        this.dictionarySize = dictionarySize;
    }
}
